//引入express
const express = require('express')
const cors = require('cors')

//创建服务对象
const app = express()
app.use(cors())

//响应预检请求
/* app.options('/hello',(request,response)=>{
	response.header('Access-Control-Allow-Origin','*')
	response.header('Access-Control-Allow-Headers','*')
	response.send()
}) */

//响应get请求，不接收参数，只是单纯返回固定数据
app.get('/hello',(request,response)=>{
	console.log('@')
	// response.header('Access-Control-Allow-Origin','*')
	response.send('你好啊！')
})

//绑定端口监听
app.listen(5002,(error)=>{
	if(!error) console.log('测试跨域服务器启动成功了！')
	else console.log('测试跨域服务器启动失败！')
})

